package com.action.mvc.auth.service;

import com.action.mvc.auth.dao.FunctionDao;
import com.action.mvc.auth.entity.Function;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Wuxiang on 2017/4/24.
 */
@Service
public class FunctionService {
    @Autowired
    FunctionDao functionDao;

    /**
     * 增加功能
     * @param function
     */
    public void addFunction(Function function) {
        functionDao.saveFunction(function);
    }

    /**
     * 根据功能id，更新url信息
     * @param id
     * @param url
     */
    public void updateUrl(Long id, String url) {
        functionDao.updateUrl(id, url);
    }

    /**
     * 分页查询 指定父节点下的子节点信息
     * @param page
     * @param size
     * @param parentId
     * @return
     */
    public List<Function> getFunctions(int page, int size, Long parentId) {
        return functionDao.findFunctions(page, size, parentId);
    }

    public void deleteById(Long id){
        functionDao.deleteById(id);
    }

    public List<Function> getALlFunctions(){
        return functionDao.getALlFunctions();
    }
}
